package com.hong.cloud.mall.practice.cartorder.mq;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 描述：发送消息
 */
@Component
public class MsgSender {
    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send(Integer productId, Integer stock) {
        /**
         * 参数1：交换机名称
         * 参数2：路由key
         * 参数3：消息内容
         */
        rabbitTemplate.convertAndSend("cloud-mall-exchange", "productStock", productId + "," + stock);
    }
}
